package chpt08;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class BufferedFileCopy {
	public static void main(String[] args) throws IOException{
		try(BufferedInputStream bis = new BufferedInputStream(new FileInputStream("test.txt"));
				BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("test.bak"))){
			byte[] buf = new byte[1024];
			int len = 0;
			while((len=bis.read(buf,0,1024))!=-1) {
				bos.write(buf,0,len);
			}			
		}
		System.out.println("File copy end.");
	}
}
